IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'DomainCreate')
	BEGIN
		DROP  Procedure  DomainCreate
	END

GO

CREATE Procedure DomainCreate
(
	@accountId int,
	@title nvarchar(200),
	@registerDate datetime,
	@expiryDate datetime,
	@domainId int OUTPUT,
	@serviceId int OUTPUT
)
AS

EXEC ServiceCreate @accountId = @accountId, @title = @title, @serviceId = @serviceId OUTPUT

INSERT INTO Domains
	(ServiceId, RegisterDate, ExpiryDate)
VALUES
	(@serviceId, @registerDate, @expiryDate)
	
SET @domainId = SCOPE_IDENTITY()

GO